﻿package SearchMovie;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;

public class NotFoundMovie extends javatitov.pages.TestBase {
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
private RemoteWebDriver movie_box;
  
  
  @Test
  public void NegativeSearchMovie() throws Exception {
		driver.get(baseUrl + "/php4dvd/");
		WebElement searchbox = driver.findElement(By.id("q"));
		searchbox.click();
	    searchbox.sendKeys(Keys.LEFT_CONTROL + "a");
	    searchbox.sendKeys(Keys.DELETE);
	    Thread.sleep(200);
	    searchbox.sendKeys("фильмаки" + Keys.RETURN);
	    driver.findElement(By.xpath("//div[text()='No movies where found.']"));
	    System.out.println(isElementPresent(By.xpath("//div[text()='No movies where found.']")) + " " + "ничего не нашлось");
  }

  
 
  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      String alertText = alert.getText();
      if (acceptNextAlert) {
        alert.accept();
      } else {
        alert.dismiss();
      }
      return alertText;
    } finally {
      acceptNextAlert = true;
    }
  }

boolean isElementPresent(By by) {
    try {
        driver.findElement(by);
        return true;
    } catch (NoSuchElementException e) {
        return false;
    }
}
}